package com.excel.qlexpress;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public enum CheckErrorConditionEnum {

    // 员工
    EMPLOY_CODE_BLACK("员工编号为空","员工编号", "employ.getUid() == null || employ.getUid().trim().isEmpty()"),
    EMPLOY_CODE_LENGTH("员工编号长度大于50","员工编号", "employ.getUid().length() > 50"),
    EMPLOY_POST_CODE_BLACK("员工职级编号为空","员工职级编号", "employ.getPostId() == null || employ.getPostId().trim().isEmpty()"),
    EMPLOY_TYPE_BLACK("员工类型为空","员工类型", "employ.getEmployeeType() == null"),
    EMPLOY_NAME_BLACK("员工名字为空","员工名字", "employ.getName() == null || employ.getName().trim().isEmpty()"),
    EMPLOY_PHONE_BLACK("手机号为空","员工手机号", "employ.getMobilePhone() == null || employ.getMobilePhone().trim().isEmpty()"),
    EMPLOY_COUNTRY_BLACK("员工国家码为空","员工国家码", "employ.getCountryCode() == null || employ.getCountryCode().trim().isEmpty()"),
    EMPLOY_CARD_EMPTY("员工证件为空","员工证件", "employ.getCardInfoList() == null || employ.getCardInfoList().isEmpty()"),
    EMPLOY_JOB_CODE_LENGTH("岗位编号限20字符以内","员工岗位", "employ.getJobCode()!= null && employ.getJobCode().length() > 20"),
    EMPLOY_JOB_NAME_LENGTH("岗位名称限20字符以内","员工岗位", "employ.getJobName()!= null && employ.getJobName().length() > 20"),



    // 组织
    ORG_IS_NULL("组织信息为空","组织信息", "org == null"),
    ORG_BIZ_CODE_BLACK("公司/部门编码为空","组织信息", "org_basic.getBusinessCode() == null || org_basic.getBusinessCode().trim().isEmpty()"),
    ORG_BIZ_NAME_BLACK("公司/部门名称为空","组织信息", "org_basic.getName() == null || org_basic.getName().trim().isEmpty()"),
    ORG_BIZ_CODE_LENGTH("公司/部门编码长度不能超过50","组织信息", "org_basic.getBusinessCode().length() > 50"),
    ORG_BIZ_CODE_CHECK_PARENT("顶层组织，只能是公司","组织信息", "org_basic.getParentBusinessCode() == null && \"D\".equals(org_basic.getType())"),
    ORG_BIZ_TYPE_BLACK("组织信息为空","组织性质", "org_basic.getType() == null || !(\"C\".equals(org_basic.getType()) || \"D\".equals(org_basic.getType()))"),





    ;


    private String validTip;
    private String groupName;
    private String expression;
    public static Map<String, CheckErrorConditionEnum> CheckConditionMap = new LinkedHashMap<>();

    CheckErrorConditionEnum(String validTip, String groupName, String expression) {
        this.validTip = validTip;
        this.groupName = groupName;
        this.expression = expression;
    }

    public String getGroupName() {
        return groupName;
    }
    public String getValidTip() {
        return validTip;
    }

    public String getExpression() {
        return expression;
    }

    public static List<CheckErrorConditionEnum> getExpressByGroup(String groupName) {
        List<CheckErrorConditionEnum> list = new ArrayList<>();
        for (CheckErrorConditionEnum e : CheckErrorConditionEnum.values()) {
            if (e.getGroupName().equals(groupName)) {
                list.add(e);
            }
        }
        return list;
    }

    static {
        for (CheckErrorConditionEnum e : CheckErrorConditionEnum.values()) {
            CheckConditionMap.put(e.name(), e);
        }
    }


}
